﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using YiSha.Util;
using YiSha.Util.Extension;
using YiSha.Util.Model;
using YiSha.Entity.OrganizationManage;
using YiSha.Model.Param.OrganizationManage;
using YiSha.Service.OrganizationManage;
using YiSha.Business.SystemManage;

namespace YiSha.Business.OrganizationManage
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2020-05-09 22:50
    /// 描 述：产品信息业务类
    /// </summary>
    public class MotoBLL
    {
        private AreaBLL areaBLL = new AreaBLL();
        private MotoService motoService = new MotoService();

        #region 获取数据
        public async Task<TData<List<MotoEntity>>> GetList(MotoListParam param)
        {
            TData<List<MotoEntity>> obj = new TData<List<MotoEntity>>();
            obj.Result = await motoService.GetList(param);
            obj.TotalCount = obj.Result.Count;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<List<MotoEntity>>> GetPageList(MotoListParam param, Pagination pagination)
        {
            TData<List<MotoEntity>> obj = new TData<List<MotoEntity>>();
           obj.Result = await motoService.GetPageList(param, pagination);
            obj.TotalCount = pagination.TotalCount;
            obj.Tag = 1;
            return obj;

            //TData<List<MotoEntity>> obj = new TData<List<MotoEntity>>();
            //areaBLL.SetAreaParam(param);
            //obj.Result = await motoService.GetPageList(param, pagination);
            //obj.TotalCount = pagination.TotalCount;
            //obj.Tag = 1;
            //return obj;
        }
        public async Task<TData<List<MotoEntity>>> GetTest(MotoListParam param, Pagination pagination)
        {
            TData<List<MotoEntity>> obj = new TData<List<MotoEntity>>();
            obj.Result = await motoService.GetPageList(param, pagination);
            return obj;

            //TData<List<MotoEntity>> obj = new TData<List<MotoEntity>>();
            //areaBLL.SetAreaParam(param);
            //obj.Result = await motoService.GetPageList(param, pagination);
            //obj.TotalCount = pagination.TotalCount;
            //obj.Tag = 1;
            //return obj;
        }
        public async Task<TData<MotoEntity>> GetEntity(long id)
        {
            TData<MotoEntity> obj = new TData<MotoEntity>();
            obj.Result = await motoService.GetEntity(id);
            if (obj.Result != null)
            {
                obj.Tag = 1;
            }
            return obj;
        }
        public async Task<TData<int>> GetMaxSort()
        {
            TData<int> obj = new TData<int>();
            obj.Result = await motoService.GetMaxSort();
            obj.Tag = 1;
            return obj;
        }
        #endregion

        #region 提交数据
        public async Task<TData<string>> SaveForm(MotoEntity entity)
        {
            TData<string> obj = new TData<string>();
            await motoService.SaveForm(entity);
            obj.Result = entity.Id.ParseToString();
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData> DeleteForm(string ids)
        {
            TData obj = new TData();
            await motoService.DeleteForm(ids);
            obj.Tag = 1;
            return obj;
        }
        #endregion

        #region 私有方法
        #endregion
    }
}
